'''
Created on 2009-9-8
This code is to abstract single molecular from liquid msd file
Format: python splitmol.py msdfile1.msd msdfile2.msd .....
@author: madlee
'''

import kuai
import kuai.molalgo


if __name__ == '__main__':
    from sys import argv
    for i in argv[1:]:
        print i
        mol = kuai.read_mol(i)
        print mol.formula()
        mols = kuai.molalgo.split_molecule(mol)
        n = len(mols)
        ids = [0]*len(mol.atoms)
        #lable the atoms as they are in the liquid msdfile
        for j in range(n):
            molJ = mols[j]
            for atomK in molJ.atoms:
                k = mol.atoms.index(atomK)
                ids[k] = j+1
        print ids
